<?php
/**
 *  企业信息控制器
 */
namespace app\msgapi\controller;

use app\BaseController;
use app\msgapi\service\HscorpInfoService;
use app\Request;

class HscorpInfo extends BaseController
{
    public function __construct(HscorpInfoService $service)
    {
        parent::__construct(app());
        $this->service = $service;
    }

    /**企业信息(展示信息)
     * @return \think\response\Json
     */
    public function huihuaCorpInfo()
    {
        return $this->service->huihuaCorpInfo();
    }


    /**获取企业密钥信息
     * @return mixed|\think\response\Json
     * @throws \Throwable
     */
    public function getCorpInfo()
    {
        return $this->service->getCorpInfo(env('wework.corpid'));//部署版,固定id为1
    }

    /**更新企业密钥信息
     * @param Request $request
     * @return \think\response\Json
     */
    public function upCorpInfo(Request $request)
    {
        $data = $request->only(['corpid','corp_name','corp_full_name','corp_logo','address_book_secret','customer_secret','msg_secret','public_key','private_key','version','agent_id','agent_secret','start_date','end_date','jssdk_file'],'post');
        return $this->service->corp_save($data,env('wework.corpid'));
    }

    /**生成公钥私钥
     * @return \think\response\Json
     */
    public function generateRsaKeys()
    {
        return $this->service->rsa_keys();
    }




}